﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DomainModel.Abstract;
using DomainModel.Entities;
using Rhino.Commons;

namespace DomainModel.Concrete
{
    public class UserRepository : IUserRepository
    {
        public User GetUser(string username)
        {
            User result = (User)
            UnitOfWork.CurrentSession.
            CreateQuery("select usr from User usr where usr.UserName =:username ")
                .SetString("username", username).UniqueResult();

            return result;
        }

        public void AddUser(User usr)
        {
            UnitOfWork.CurrentSession.Save(usr);
        }

        public void DeleteUser(User usr)
        {
            UnitOfWork.CurrentSession.Delete(usr);
        }

    }
}
